/**
 * 百度统计
 */
function statistics(id) {
  var _hmt = _hmt || [];
  (function() {
    var src = `https://hm.baidu.com/hm.js?${id}`;

    //每次执行前，先移除上次插入的代码
    document.getElementById('baidu_tj') &&
      document.getElementById('baidu_tj').remove();
    var hm = document.createElement('script');
    hm.src = src;
    hm.id = 'baidu_tj';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(hm, s);

    _hmt.push('_requirePlugin', 'UrlChangeTracker', {
      shouldTrackUrlChange: function(newPath, oldPath) {
        return newPath && oldPath;
      },
    });
  })();
}

export { statistics };
export default {
  statistics,
};
